home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mikecom / tximd.asm < prev    next >
Assembly Source File  |  1987-05-16  |  3KB  |  78 lines

  1.  
  2. title TRANSMIT BLOCK DATA IMMEDIATE
  3. include subfx.h
  4.  
  5. ;  Mike Dumdei,  6 Holly Lane,  Texarkana TX  75503
  6.  
  7. IMPORT_NEAR     <__tx_inton, __txblk_fill>
  8.  
  9. ;*****************************************************************************
  10. ; ASYNC_TXIMD -- Gets block passed by C caller and puts it in the transmit
  11. ; buffer ahead of anything else already in the buffer.  Returns R_TXERR if
  12. ; the port argument was invalid or there was insufficient room in the buffer.
  13. ; Returns number bytes left in buffer if tx was successful.
  14. ;*****************************************************************************
  15. begseg          COMM_TEXT
  16. publicproc      _async_tximd
  17.         push    bp
  18.         mov     bp,sp
  19.         push    si
  20.         push    di
  21.         push    es              ;setup stack and save regs
  22.         call    __ck_port_arg   ;ck port argument & load pointers
  23.         mov     ax,R_TXERR
  24.         jz      async_texit2    ;bad port if ZR
  25.         mov     cx,TxImdCnt
  26.         jcxz    get_txfree      ;exit if chars to tx = 0
  27.         cli
  28.         mov     bx,TX_FREE
  29.         sub     bx,cx           ;ck if enough room in the buffer
  30.         jc      async_texit2    ;and exit if not
  31.         mov     TX_FREE,bx      ;else set new TX_FREE value
  32.         mov     bx,TX_OUT       ;get ptr to nxt char to tx would have been
  33.         sub     bx,cx
  34.         cmp     bx,TX_TOP
  35.         jnb     set_new_out
  36.         sub     bx,TX_TOP
  37.         add     bx,TX_BTM
  38. set_new_out:
  39.         mov     TX_OUT,bx       ;adjust TX_OUT to point to new nxt char out
  40.         mov     di,bx
  41.         mov     es,RXTX_SEG     ;get seg of rx/tx bufrs
  42.         mov     bx,TxImdOfst    ;ES:DI=new TX_OUT   BX=blk ofst
  43.         mov     dx,5
  44.         cmp     cx,dx           ;going to tx 5 chars, start tx, reenable
  45.         ja      more_than5      ; interrupts, & then finish the move
  46.         xor     dx,dx
  47.         push    dx              ;none left to move aftr 1st group if < 5 in 1st
  48.         jmp s   move_first
  49. more_than5:
  50.         sub     cx,dx
  51.         push    cx              ;bytes left to move after moving 1st 5
  52.         mov     cx,dx           ;set CX=5 -- nbr to move before tx is started
  53. move_first:
  54.         call    __txblk_fill    ;move 1st group to tx buffer
  55.         and     TX_STAT,n B_TXEMPTY ;clear bit that indicates nothing to tx
  56.         jnz     txint_ok2       ;NZ = tx alrdy on or flow cntrl halt active
  57.         push    bx
  58.         call    __tx_inton      ;else start things going if they're not alrdy
  59.         pop     bx
  60. txint_ok2:
  61.         sti
  62.         pop     cx              ;number bytes left to put in buffer
  63.         jcxz    get_txfree
  64.         call    __txblk_fill    ;move rest of block to tx buf if there is more
  65. get_txfree:
  66.         mov     ax,TX_FREE
  67. async_texit2:
  68.         sti
  69.         pop     es
  70.         pop     di
  71.         pop     si
  72.         mov     sp,bp
  73.         ret                     ;restore regs and exit
  74. _async_tximd    endp
  75.  
  76. endseg          COMM_TEXT
  77.         end
  78.